package com.bjpowernode.controller;

import com.bjpowernode.entity.TActivity;
import com.bjpowernode.entity.query.ActivityQuery;
import com.bjpowernode.common.result.Result;
import com.bjpowernode.service.ActivityService;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Controller
@RequiredArgsConstructor
@RestController
public class ActivityController {

    private final ActivityService activityService;

    @GetMapping("/api/activities")
    public Result getActivityByPage(Integer current, ActivityQuery activityQuery){
        PageInfo<TActivity> pageInfo = activityService.getActivitiesByPage(current, activityQuery);
        return Result.OK(pageInfo);
    }

    @GetMapping("/api/activity/{id}")
    public Result getActivityById(@PathVariable("id") Integer id){
        TActivity tActivity = activityService.getActivityById(id);
        return Result.OK(tActivity);
    }
}
